.<template>
	<div>
		<el-dropdown>
        <span class="el-dropdown-link">
        <span style="margin-right: 15px;">欢迎登录:</span>
		    {{userName}}
        <i class="el-icon-arrow-down el-icon--right"></i>
		  </span>
		  <el-dropdown-menu slot="dropdown">
		    <!-- <el-dropdown-item>个人信息</el-dropdown-item> -->
		    <el-dropdown-item @click.native="exitMethod">退出</el-dropdown-item>
		  </el-dropdown-menu>
		</el-dropdown>
	</div>
</template>

<script>
  export default {
    data() {
      return{
        userName:"",
      }
    },
    mounted() {
      this.setUserName()
    },
    methods: {
      exitMethod(){
        var self = this;
        var sucLoginUserTo = JSON.parse(sessionStorage.getItem("manager"))
        console.log(sucLoginUserTo)
        this.$http.post("/api/CakeShop/loginOut", 
          sucLoginUserTo
        ).then(
          function(res){
            self.$message({
            	duration: 1500,
            	message: "退出成功！",
            	type: "success",
            	onClose: function() {
            		self.loading = false;
                //返回登录页
                sessionStorage.removeItem("manager")
                self.$router.push({name:'Login'})
            	},
            });
          },
          function(err){}
        )
      },
      setUserName(){
        var admin = sessionStorage.getItem("admin")
        this.userName = admin
      }
    },
  }

</script>

<style scoped>
	  .el-dropdown-link {
	    cursor: pointer;
	    color: #ffffff;
	  }
	  .el-icon-arrow-down {
	    font-size: 12px;
	  }
</style>
